package com.hopes.bizz.risk.transfer.bean.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.hopes.bizz.risk.transfer.constant.RiskConstant;
import com.hopes.bizz.risk.transfer.validation.*;
import com.hopes.bizz.risk.transfer.validation.group.SeqFour;
import com.hopes.bizz.risk.transfer.validation.group.SeqOne;
import com.hopes.bizz.risk.transfer.validation.group.SeqThree;
import com.hopes.bizz.risk.transfer.validation.group.SeqTwo;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author lyb
 * @version 1.0
 * @description: 隐患任务配置
 * @date 2024/2/1 11:15
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class RiskMeasuresTaskDto extends RiskBaseLogicDto {

    private static final long serialVersionUID = -8264864854250693411L;

    @NotBlank(message = "管控措施ID为空", groups = SeqOne.class)
    @UUID(message = "管控措施ID不符合UUID正则", groups = SeqTwo.class)
    private String riskMeasureId;

    @NotBlank(message = "隐患排查内容为空", groups = SeqOne.class)
    private String troubleshootContent;

    @NotNull(message = "巡检周期为空", groups = SeqOne.class)
    @Min(value = 1, message = "最小周期不能小于1", groups = SeqTwo.class)
    private Integer checkCycle;

    @NotBlank(message = "巡检周期单位为空", groups = SeqOne.class)
    @Include(item = {"小时", "天", "月", "年"}, message = "巡检周期单位字典项不符合字典枚举,请核对文档<<巡检周期单位>>字典", groups = SeqTwo.class)
    private String checkCycleUnit;

    @NotBlank(message = "任务开始时间为空", groups = SeqOne.class)
    @DateTime(message = "<<任务开始时间>>不符合时间格式", groups = SeqTwo.class)
    private String taskStartTime;
    /**
     * 工作开始时间
     **/
    @Time(allowEmpty = true, message = "<<工作开始时间>>不符合时间格式", groups = SeqFour.class)
    private String workStartTime;
    /**
     * 工作结束时间
     **/
    @Time(allowEmpty = true, message = "<<工作结束时间>>不符合时间格式", groups = SeqFour.class)
    private String workEndTime;
    /**
     * 工作日类型
     **/
    @Include(allowEmpty = true, item = {"0", "1", "2"}, message = "工作日类型字典项不符合字典枚举,请核对文档<<工作日类型>>字典", groups = SeqOne.class)
    private String workDayType;

    @NotBlank(message = "任务类型为空", groups = SeqOne.class)
    @Include(item = {"0", "1", "2", "3"}, message = "任务类型数据错误,请核对文档<<任务类型>>字典", groups = SeqTwo.class)
    private String workType = "0";
    /**
     * 包保任务对应项
     **/
    private String taskNum;

    @HazTaskNum(groups = SeqThree.class)
    @JSONField(serialize = false)
    public String getHazTaskNum() {
        return workType + RiskConstant.VALIDATOR_JOIN + taskNum;
    }

    @WorkTime(message = "工作开始时间为空", groups = SeqThree.class)
    @JSONField(serialize = false)
    public String getWorkStartTimeAndUnit() {
        return checkCycleUnit + RiskConstant.VALIDATOR_JOIN + workStartTime;
    }

    @WorkTime(message = "工作结束时间为空", groups = SeqThree.class)
    @JSONField(serialize = false)
    public String getWorkEndTimeAndUnit() {
        return checkCycleUnit + RiskConstant.VALIDATOR_JOIN + workEndTime;
    }
}
